package com.zx.idc.backend.gui.common;

import com.zx.idc.backend.gui.common.base.BaseAddApi;
import com.zx.idc.backend.gui.common.base.BaseDeleteApi;
import com.zx.idc.backend.gui.common.base.BaseNotReportTotalApi;
import com.zx.idc.backend.gui.common.base.BaseUpdateApi;
import com.zx.idc.ds.common.entity.BaseEntity;
import com.zx.idc.ds.common.service.BaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Optional;

/**
 * 基础的 {@link BaseApi} 实现，主要添加了一些通用方法
 *
 * @param <Service> 服务层的类
 * @param <Entity>  实体类
 * @author rxliuli
 */
public class BasicBaseApi<Service extends BaseService<Entity>, Entity extends BaseEntity> extends BaseApi
    implements BaseAddApi<Service, Entity>,
    BaseNotReportTotalApi<Service, Entity>,
    BaseDeleteApi<Service, Entity>,
    BaseUpdateApi<Service, Entity> {

    protected final Logger log = LoggerFactory.getLogger(getClass());
    /**
     * 自动注入业务类的 Bean
     */
    @SuppressWarnings({"SpringJavaInjectionPointsAutowiringInspection"})
    @Autowired
    protected Service service;

    @Override
    public Optional<Service> getService() {
        return Optional.of(service);
    }
}
